import request from '@/config/axios'

// 附件信息 VO
export interface AttachmentVO {
  fileId: string // ID
  projectId: number // 项目ID
  relevanceId: string // 所属ID;属于哪个表ID
  fileName: string // 文件名称
  filePath: string // 文件路径
  url: string // URL
  fileType: string // 文件类型
  relevanceName: string // 关联名称
  originalFileName: string // 文件原名
  netUrl: string // 外网地址
}

// 附件信息 API
export const AttachmentApi = {
  // 查询附件信息分页
  getAttachmentPage: async (params: any) => {
    return await request.get({ url: `/pypm/attachment/page`, params })
  },

  // 查询附件信息详情
  getAttachment: async (id: number) => {
    return await request.get({ url: `/pypm/attachment/get?id=` + id })
  },

  // 新增附件信息
  createAttachment: async (data: AttachmentVO) => {
    return await request.post({ url: `/pypm/attachment/create`, data })
  },

  // 修改附件信息
  updateAttachment: async (data: AttachmentVO) => {
    return await request.put({ url: `/pypm/attachment/update`, data })
  },

  // 删除附件信息
  deleteAttachment: async (id: number) => {
    return await request.delete({ url: `/pypm/attachment/delete?id=` + id })
  },

  // 导出附件信息 Excel
  exportAttachment: async (params) => {
    return await request.download({ url: `/pypm/attachment/export-excel`, params })
  }
}